<script setup lang="ts">
import { useUserStore } from '@/stores/user'

import { useRouter } from 'vue-router'

const router = useRouter()
async function auth() {
  var user = useUserStore()
  if (!user.getToken()) {
    router.replace({ path: '/error/403' })
    return
  }
  try {
    await user.auth()
    router.replace({ path: '/' })
  } catch (error) {
    user.clearToken()
    console.log(error)
    router.replace({ path: '/error/403' })
  }
}
auth()
</script>

<template></template>
<style scoped></style>
